#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    static Point* getInstance(){
        
        if(_pinstance == nullptr){
            _pinstance = new Point();
        }
        return _pinstance; 
    }

    static void destroy(){
        if(_pinstance != nullptr){
            delete _pinstance;
            _pinstance = nullptr;
        }
    }

    void init(int x, int y){
        _x = x;
        _y = y;
    }

    void print(){
        cout << "(" << _x << ", " << _y << ")" << endl;
    }

    Point(const Point& rhs) = delete;
    Point& operator=(const Point& rhs) = delete;
private:
    Point(int x = 0, int y = 0)
        : _x(x)
        , _y(y) {
        cout << "Point(int x = 0, int y = 0)" << endl;
    }
    
    ~Point(){
        cout << "~Point()" << endl;
    }
    double _x;
    double _y;
    static Point* _pinstance;
};
Point* Point::_pinstance = nullptr;


int main(void)
{
    Point::getInstance()->init(3, 4);
    Point::getInstance()->print();
    Point::getInstance()->init(5, 6);
    Point::getInstance()->print();
    cout << Point::getInstance() <<endl;
    cout << Point::getInstance() <<endl;
    Point::destroy();
    Point::destroy();
    return 0;
}